package gewu.suleju.sevice.imp;

import gewu.suleju.dao.iml.IBrokerAgentHouseDao;
import gewu.suleju.dao.iml.IHouseDetailDao;
import gewu.suleju.model.pojo.HouseInfor;
import gewu.suleju.sevice.IBrokerAgentHousService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class BrokerAgentHousServiceImp  implements IBrokerAgentHousService {
    private BrokerAgentHousServiceImp brokerAgent;
   @Autowired
    IHouseDetailDao iHouseDetailDao;
    @Autowired
    IBrokerAgentHouseDao  iBrokerAgentHouseDao;
    //名下房源，未出租
    @Override
    public List<HouseInfor> findHouseIng(Integer brokerid) {
        return iBrokerAgentHouseDao.findHouseIng(brokerid);
    }
    //名下房源，已出租
    @Override
    public List<HouseInfor> findHouseEnd(Integer brokerid) {
        return iBrokerAgentHouseDao.findHouseEnd(brokerid);
    }
    //返回代理未出租的房子信息和照片集合
    public HashMap brokerAgentIng(Integer brokerid ) {
        HashMap<String,Object> agentIng = new HashMap<String,Object>();
        List<HouseInfor>  houseList =iBrokerAgentHouseDao.findHouseIng(brokerid);
        String[] housepicIng=new String[houseList.size()];
        for (int i = 0; i <houseList.size() ; i++) {
            HouseInfor  house=houseList.get(i);
            String onePic= iHouseDetailDao.findOneHousePic(house.getId());
          housepicIng[i]=onePic;
        }
        agentIng.put("houseList",houseList);
        agentIng.put("housepic",housepicIng);
        return agentIng;
    }
    //返回代理已经出租的房子信息和照片集合
    public HashMap brokerAgentEnd(Integer brokerid ) {
        HashMap<String,Object> agentEnd = new HashMap<String,Object>();
        List<HouseInfor>  houseList =iBrokerAgentHouseDao.findHouseEnd(brokerid);
        String[] housepic=new String[houseList.size()];
        for (int i = 0; i <houseList.size() ; i++) {
            HouseInfor  house=houseList.get(i);
            String onePic= iHouseDetailDao.findOneHousePic(house.getId());
            housepic[i]=onePic;
        }
        agentEnd.put("houseList",houseList);
        agentEnd.put("housepic",housepic);
        return agentEnd;
    }

}
